/**
 * Copyright (c) 2016-2020 https://github.com/zhaohuatai
 *
 * contact 824069438@qq.com
 *  
 */
package org.zfes.snowier.cloud.zbss.layer.tc;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.auth.AuhencFilter;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.auth.LogoutFilter;

@Configuration("newWebRegisteConfiguration")
public class WebRegisteConfiguration {

	@Autowired
	ZTCConfigProperties configProperties;
	 @Bean
	 public FilterRegistrationBean auhencFilter() {
		 FilterRegistrationBean registrationBean = new FilterRegistrationBean();
		 registrationBean.setName("auhencFilter");
		 AuhencFilter auhencFilter = new AuhencFilter();
		 registrationBean.setFilter(auhencFilter);
		 registrationBean.setOrder(1);
		 auhencFilter.setConfigProperties(configProperties);
		 List<String> urlList = new ArrayList<String>();
		 urlList.add("/*");
		 registrationBean.setUrlPatterns(urlList);
		 return registrationBean;
	 } 
	 
	 @Bean 
	 public FilterRegistrationBean logoutFilter() {
		 FilterRegistrationBean registrationBean = new FilterRegistrationBean();
		 registrationBean.setName("logoutFilter");
		 LogoutFilter logoutFilter = new LogoutFilter();
		 registrationBean.setFilter(logoutFilter);
		 registrationBean.setOrder(3);
		 List<String> urlList = new ArrayList<String>();
		 urlList.add("/auth/logout");
		 registrationBean.setUrlPatterns(urlList);
		 return registrationBean;
	 } 
}
